package com.byCreatetion.adabter;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.byCreation.t_globe.R;

public class MainmenuListAdapter extends BaseAdapter {	
    private Activity activity;
    private LayoutInflater inflater=null;
    ArrayList<HashMap<String, Object>> MyArrList = new ArrayList<HashMap<String, Object>>();
    
    public MainmenuListAdapter(Activity a,ArrayList al ) {
    	
    	activity = a;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        MyArrList=al;
       
    }
    
    private class ViewHolder {
    	private TextView txt_title;
		private ImageView img_arrow;
	}


   
    @Override
	public int getCount() {

        return MyArrList.size();
    }
    @Override
    public Object getItem(int position) {
        return position;
    }
    @Override
    public long getItemId(int position) {
        return position;
    }
    
    public View getView(final int position, View convertView, ViewGroup parent) {
      
    	View vi=convertView;
    	final ViewHolder holder;
    	
        if(convertView==null)
        {
	        vi = inflater.inflate(R.layout.item_mainmenu_listview, null);
	        holder = new ViewHolder();
		   
		    holder.txt_title= (TextView)vi.findViewById(R.id.txt_title);
		    holder.img_arrow=(ImageView)vi.findViewById(R.id.img_arrow);
		   
		    
			vi.setTag(holder);	
	 	
	 		
	 		
	
	 		
	}else 
    {
	
    		holder = (ViewHolder)vi.getTag();
    }
            
        holder.txt_title.setText(MyArrList.get(position).get("Title").toString());
        if(	MyArrList.get(position).get("Data").toString().equals("")||
        		MyArrList.get(position).get("Data").toString().equals("[]")	)
        {
        	holder.img_arrow.setVisibility(View.INVISIBLE);
        }
        else
        	holder.img_arrow.setVisibility(View.VISIBLE);
        //=================================SetData===================================
      
	

        
	
	return vi;
    }

}



